/* GUI CONVERTED from rcabsdd.p (converter v1.76) Mon Jul 30 07:02:28 2001 */
/* rcabsdd.p - DELETING USER FIELDS AND LINE CHARGES FROM A SHIPPER     */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.4 $                                                 */
/*                                                                      */
/* $Revision: 1.4 $   BY: Steve Nugent   DATE: 07/16/01 ECO: *P006* */
/*V8:ConvertMode=Maintenance                                            */
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*         THIS PROGRAM IS A BOLT-ON TO STANDARD PRODUCT MFG/PRO.           */
/* ANY CHANGES TO THIS PROGRAM MUST BE PLACED ON A SEPARATE ECO THAN        */
/* STANDARD PRODUCT CHANGES.  FAILURE TO DO THIS CAUSES THE BOLT-ON CODE TO */
/* BE COMBINED WITH STANDARD PRODUCT AND RESULTS IN PATCH DELIVERY FAILURES.*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */

/*-----------------------------------------------------------------------------
  Purpose: This program deletes any shipper line charges (absl_det) and
       user fields when the shipper line is being deleted.
  Notes:
------------------------------------------------------------------------------*/


{mfdeclre.i}

define input parameter abs_recid as recid no-undo.

for first abs_mstr fields(abs_order abs_line abs_id
                        abs_shipfrom abs_item)
  no-lock where recid(abs_mstr) = abs_recid:
end.

if not available abs_mstr then leave.
/* DELETE THE USER FIELDS FROM THE SHIPPER */

for each absd_det exclusive-lock
   where
      absd_abs_id = abs_id
   and absd_shipfrom = abs_shipfrom:

   delete absd_det.

end.

/* DELETE THE LINE CHARGES FROM THE SHIPPER              */
/* DELETE THE LINE CHARGES CREATED ON THE SALES ORDER    */
/* FROM THE SHIPPER AND DECREMENT THE TIMES CHARGED ON   */
/* THE LINE CHARGES THAT ORIGINATED FROM THE SALES ORDER,*/
/* WHICH WILL NOT BE DELETED                             */

for each absl_det exclusive-lock
   where
      absl_abs_id = abs_id
   and absl_abs_shipfrom = abs_shipfrom
   and absl_order = abs_order
   and absl_ord_line = integer(abs_line):

   for each sodlc_det exclusive-lock
      where
         sodlc_order = absl_order
      and sodlc_ord_line = absl_ord_line
      and sodlc_lc_line = absl_lc_line:

      if sodlc_owned_by = abs_id then
         delete sodlc_det.
      else
        if sodlc_times_charged > 0 then
           assign
              sodlc_times_charged = sodlc_times_charged - 1.
   end.

   delete absl_det.
end.


/* DELETE THE CONTAINER CHARGES CREATED ON THE SALES ORDER*/
/* FROM THE SHIPPER */

for each abscc_det exclusive-lock
   where
      abscc_abs_id = abs_id
   and abscc_abs_shipfrom = abs_shipfrom
   and abscc_order = abs_order
   and abscc_ord_line = integer(abs_line)
   and abscc_container = abs_item:

   delete abscc_det.

end.
